//
//  TDAlertView.h
//  EVCLub
//
//  Created by Xuni Inc. on 12/27/12.
//  Copyright (c) 2012 tlm. All rights reserved.
//

#import <UIKit/UIKit.h>

//仅TDAlertView内部使用
#define AlertIGotItBtnTitleKey @"知道了"
#define AlertOKBtnTitleKey     @"确定"
#define AlertCancelBtnTitleKey @"取消"

// 常用的Alert按钮名称 方便本地化
#define kAlertIGotItBtnTitle    [TDAlertView localizedStringForBtnKey:AlertIGotItBtnTitleKey]

#define kAlertOKBtnTitle        [TDAlertView localizedStringForBtnKey:AlertOKBtnTitleKey]

#define kAlertCancelBtnTitle    [TDAlertView localizedStringForBtnKey:AlertCancelBtnTitleKey]

@class TDAlertView;

@protocol TDAlertViewDelegate <NSObject>

@optional

//点击按钮对话框自动消失，并有回调
-(BOOL)shouldDisappearAlertView:(TDAlertView *)alertView onClickedButtonAtIndex:(NSInteger)buttonIndex;
//消失了
- (void)TDAlertView:(TDAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;

-(void)alertView:(TDAlertView *)alertView willMoveToView:(UIView*)superView;

-(void)alertView:(TDAlertView *)alertView didMoveToView:(UIView*)superView;

-(void)alertView:(TDAlertView *)alertView didClickOutside:(UIView *)contentView;
@end

typedef void(^TDAlertBlock)(NSInteger index);

@interface TDAlertView : UIView

@property (nonatomic,weak) id<TDAlertViewDelegate> delegate;

@property (assign, nonatomic) BOOL animationDisabled;

@property (nonatomic,copy,readonly)NSString* strMessage;

@property (nonatomic,copy,readonly)NSString* strTitle;

@property (nonatomic,retain)UIView* contentView;

@property (nonatomic,readonly) NSUInteger buttonCount;

@property (nonatomic,strong)id userData;

@property (nonatomic,readonly)BOOL bShowing;

@property (nonatomic, retain,readonly) UIImage *leftIcon;

@property(nonatomic,copy) TDAlertBlock block;

@property (nonatomic, assign) BOOL hideDefaultBackground;

@property (nonatomic, copy) UIColor *maskColor;
@property (nonatomic, copy) void(^contentDidAddedBlock)();
+ (NSString*)localizedStringForBtnKey:(NSString*)BtnKey;

+ (id)messageBox:(NSString*)tips;//普通的

+ (id)warningMessage:(NSString*)tips;//带有警告图的

+ (id)viewWithContentView:(UIView*)contentView
             cancelButton:(NSString*)cancel
             otherButtons:(NSArray*)buttons
                 delegate:(id<TDAlertViewDelegate>)delegate;
+ (id)viewWithTitle:(NSString*)title
            message:(NSString *)message
       cancelButton:(NSString*)cancel
       otherButtons:(NSArray*)buttons
           delegate:(id<TDAlertViewDelegate>)delegate;

+ (id)viewWithTitle:(NSString*)title
           leftIcon:(UIImage*)leftIcon
            message:(NSString *)message
       cancelButton:(NSString*)cancel
       otherButtons:(NSArray*)buttons
           delegate:(id<TDAlertViewDelegate>)delegate;

+ (id)viewWithWarningTitle:(NSString*)title //带有警告图的
                   message:(NSString *)message
              cancelButton:(NSString*)cancel
              otherButtons:(NSArray*)buttons
                  delegate:(id<TDAlertViewDelegate>)delegate;

+ (id)viewWithContentView:(UIView*)contentView
                withTitle:(NSString*)title
             cancelButton:(NSString*)cancel
             otherButtons:(NSArray*)buttons
                 delegate:(id<TDAlertViewDelegate>)delegate;

- (instancetype)initWithTitle:(NSString *)title
                      message:(NSString *)message
            cancelButtonTitle:(NSString *)cancelButtonTitle
                  clickButton:(TDAlertBlock)_block
            otherButtonTitles:(NSArray *)otherButtonTitles;
//当前是否有弹窗
+ (BOOL)hasAlertView;

//判断是否有弹窗，调用show时为真，调用dismiss就为假，无视动画
+ (BOOL)isExist;

- (void)dismissIntemidialy;
- (void)show;

- (void)showInView:(UIView*)supview;
- (void)showInView:(UIView*)supview centerOffset:(CGSize)centerOffset;
- (void)dismiss;

- (NSString*)titleForButton:(NSUInteger)index;
@end
